import type { OfficeCostVO, OfficeCostForm, OfficeCostQuery } from './model';

import type { ID, IDS } from '#/api/common';
import type { PageResult } from '#/api/common';

import { commonExport } from '#/api/helper';
import { requestClient } from '#/api/request';

/**
* 查询办公费用单列表
* @param params
* @returns 办公费用单列表
*/
export function officeCostList(params?: OfficeCostQuery) {
  return requestClient.get<PageResult<OfficeCostVO>>('/trade/officeCost/list', { params });
}

/**
 * 导出办公费用单列表
 * @param params
 * @returns 办公费用单列表
 */
export function officeCostExport(params?: OfficeCostQuery) {
  return commonExport('/trade/officeCost/export', params ?? {});
}

/**
 * 查询办公费用单详情
 * @param id id
 * @returns 办公费用单详情
 */
export function officeCostInfo(id: ID) {
  return requestClient.get<OfficeCostVO>(`/trade/officeCost/${id}`);
}

/**
 * 新增办公费用单
 * @param data
 * @returns void
 */
export function officeCostAdd(data: OfficeCostForm) {
  return requestClient.postWithMsg<void>('/trade/officeCost', data);
}

/**
 * 更新办公费用单
 * @param data
 * @returns void
 */
export function officeCostUpdate(data: OfficeCostForm) {
  return requestClient.putWithMsg<void>('/trade/officeCost', data);
}

/**
 * 删除办公费用单
 * @param id id
 * @returns void
 */
export function officeCostRemove(id: ID | IDS) {
  return requestClient.deleteWithMsg<void>(`/trade/officeCost/${id}`);
}

/**
 * 作废
 * @param data 包含id
 * @returns void
 */
export function officeCostInvalidate(data: { id: ID}) {
  return requestClient.postWithMsg<void>(`/trade/officeCost/invalidate`, data);
}

/**
 * 办公费用单提交审核
 * @param data ids
 * @returns void
 */
export function officeCostSubmit(data: IDS) {
  return requestClient.post<void>(`/trade/officeCost/submit`, data);
}

/**
 * 办公费用单审核
 * @param id id
 * @param passed 是否通过
 * @param rejectReason 拒绝理由
 * @returns void
 */
export function officeCostApprove(id: ID, passed: boolean, rejectReason?: string) {
  return requestClient.postWithMsg<void>(`/trade/officeCost/approve`, {
    id: id,
    passed: passed,
    rejectReason: rejectReason,
  });
}
